import { defineStore } from "pinia";
import store from "@/store";

// 定义接口以确保类型安全
interface FormStoreState {
  formList: any[]; // 根据实际数据类型替换 `any[]`
  crudList: Record<string, any>; // 根据实际数据类型替换 `any`
}

// 默认配置对象
const defaultConfig: FormStoreState = {
  formList: [],
  crudList: {}
};

const useFormStore = defineStore("form", {
  state: (): FormStoreState => ({ ...defaultConfig }),

  getters: {
    getState(state): FormStoreState {
      return { ...state };
    }
  },

  actions: {
    updateSettings(partial: Partial<FormStoreState>) {
      this.$patch(partial);
    }
  }
});

export default useFormStore;
